import { Divider, Pagination } from "antd";
import cm from "classnames";
import { useState } from "react";
import Card from "./components/Card";
import styles from "./index.module.less";
import { usePagination, useRequest } from "ahooks";
import { getFavoriteList } from "@/services/details";
import {history} from '@umijs/max';

const Collect = () => {
  const userInfo = JSON.parse(localStorage.getItem('userInfo'))

  const {data} = useRequest(() => {
    return getFavoriteList({userId: userInfo.id}).then((res) => {
        if (res.code === 200) {
            return res.data;
        }
    })
  })
  return (
    <div className={cm(styles.CollectStyle)}>
      <Divider style={{ borderColor: "#7cb305" }} orientation="start">收藏商品</Divider>
      <div className={cm(styles.list, "managerRow", "managerWrap")}>
        {data?.map((item) => {
          return (
            <div style={{ marginRight: "10px" }}>
              <Card
                data={item}
                onClick={() => {
                    history.push(`/details/${item.goodsId}`);
                }}
              />
            </div>
          );
        })}
      </div>
    </div>
  );
};

export default Collect;
